package com.hfy.admin.service.impl;

import com.hfy.admin.mapper.DraftMapper;
import com.hfy.admin.service.DraftService;
import com.hfy.model.po.draft.DraftMusicPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import result.Result;

import java.util.List;

/**
 * @ author 韩
 * time: 2024/7/16 2:50
 */

@Service
public class DraftServiceImpl implements DraftService {

    @Autowired
    private DraftMapper draftMapper;


    @Override
    public Result applyRecover(Long account) {
        // 直接去数据库里查询草稿箱里的信息
        List<DraftMusicPo> musicList = draftMapper.getInfoByAccount(account);
        return Result.ok(musicList);
    }

    @Override
    public Result delDraftMusic(Long id) {
        draftMapper.delDraftMusic(id);
        return Result.ok();
    }

    @Override
    public Result saveUploadMusicDraft(String musicUrl, Long account) {

        if (musicUrl == null || account == null) {
            return Result.error("参数不能为空");
        }
        draftMapper.insertDraftRecord(musicUrl, account);

        return Result.ok();
    }
}
